<?php
class IndexAction extends Action
{
    public function index(){
		header("Content-Type:text/html;Charset=utf-8");
		$domain=$_GET["domain"];
		if($domain){
			$model		= M("url");
			$list			= $model->getByDomain($domain);
			$site			= $list;
			if(empty($site) or $_GET["refresh"]){
				set_time_limit(0);
				$site								= site($domain);
				$site["domain"]				= $domain;
				$site["web"]					= GetServerInfo($domain);
				$site["ip"]						= GetDomainIp($domain);
				$site["whois"]				= GetWhois($domain);
				$site["baiducount"]		= GetBaidu($domain,0);
				$site["baidulcount"]		= GetBaidu($domain,1);
				$site["googlecount"]		= GetGoogle($domain,0);
				$site["googlelcount"]		= GetGoogle($domain,1);
				$site["bingcount"]			= GetBing($domain,0);
				$site["binglcount"]			= GetBing($domain,1);
				$site["yahoocount"]		= GetYahoo($domain,0);
				$site["yahoolcount"]		= GetYahoo($domain,1);
				$site["sosocount"]			= GetSoso($domain,0);
				$site["sosolcount"]		= GetSoso($domain,1);
				$site["youdaocount"]		= GetYoudao($domain,0);
				$site["youdaolcount"]	= GetYoudao($domain,1);
				$site["sogoucount"]		= GetSogou($domain,0);
				$site["sogoulcount"]		= GetSogou($domain,1);
				$site["sogoupr"]			= GetSogouPR($domain);
				$site["pr"]						= PageRank($domain);
				$site								= $site + alexa($domain);
				if(empty($list)){
					$id		= $model->add($site);
				}else{
					$map["domain"]	= $domain;
					$id		= $model->where($map)->save($site);
				}
			}
			$head["title"]				= $domain . " - domains lookup";
			$head["keywords"]	= $domain . ",www." . $domain . ",domains,ip";
			$this->assign("domain",$domain);
			$this->assign("head",$head);
			$this->assign("site",$site);
		}else{

		}
        $this->display();
    }

	function test(){
		//echo GetSogou("tuspark.cn",0);
		//$domain	= "www.tuspark.cn";
		//echo gethostbyname($domain);

		$domain	= "http://www.tuspark.cn/";
		$domain	= "http://www.kbl.net/";


		//site($domain);
		dump(whois($domain));
		//echo GetYoudao($domain,1);
		//echo GetGoogle($domain,1);
	}

}
?>